'use strict';

module.exports = app => {
  const { STRING, INTEGER, DATE, BOOLEAN } = app.Sequelize;

  const Resource = app.model.define('resource', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    pid: INTEGER,
  //  router_name: STRING(50),
  //  controller_name: STRING(200),
    type: STRING(10), // 菜单menu，页面page，按键button, 接口api
  //  url: STRING(200),
    icon: STRING(100),
    router_id: INTEGER,
    sort: INTEGER,
    description: STRING(200),
    status: BOOLEAN,
    created_at: DATE,
    updated_at: DATE,
  });

  Resource.associate = function() {
    app.model.Resource.belongsTo(app.model.Router, { foreignKey: 'routerId' });
  };

  return Resource;
};
